習慣上的寫法


Posted by mijouhsieh on 2023-05-01

outline:
Promise 物件實例中,

1 Promise 物件實例中,例子裡沒有設計 reject - catch 的段落,因此參數寫 _reject

在習慣上,加底線表示後面沒有用到這個參數。

 new Promise((resolve, _reject) => {
    for (const [user_index, user] of users.entries()) {
      // 創建使用者資料(user): model.create
      UserModel.create({
        ...user
      }).then((user) => {
        // 對每個user建立相對應餐廳資料
        return RestaurantModel.create(restaurants)
      }).then(() => {
        resolve()
      }).catch(error => {
        console.log(error)
      })
    }
  }).then(() => {
    // 等待所有使用者的餐廳資料創建完成
    console.log('所有使用者與餐廳資料創建完成')
    process.exit()
  })

#習慣上的寫法







Related Posts

[第一週] 認識  Git  及常用指令整理

[第一週] 認識 Git 及常用指令整理

D19_開始第三週

D19_開始第三週

[極短篇] 資料庫的 ACID 是什麼?

[極短篇] 資料庫的 ACID 是什麼?


Comments